package com.example.web.controller;
import com.example.web.SysConst;
import com.example.web.dto.*;
import com.example.web.dto.query.*;
import com.example.web.entity.*;
import com.example.web.mapper.*;
import com.example.web.service.*;
import com.example.web.tools.dto.*;
import com.example.web.tools.exception.CustomException;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import lombok.SneakyThrows;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 用户地址控制器
 */
@RestController()
@RequestMapping("/UserAddress")
public class UserAddressController {
    @Autowired()
    private  UserAddressService _UserAddressService;
    @Autowired()
    private UserAddressMapper _UserAddressMapper;
    /**
     * 用户地址分页查询
     */
    @RequestMapping(value = "/List", method = RequestMethod.POST)
    @SneakyThrows
    public PagedResult<UserAddressDto> List(@RequestBody UserAddressPagedInput input)  {
        return _UserAddressService.List(input);
    }
     /**
     * 单个用户地址查询接口
     */
    @RequestMapping(value = "/Get", method = RequestMethod.POST)
    @SneakyThrows
    public UserAddressDto Get(@RequestBody UserAddressPagedInput input) {

        return _UserAddressService.Get(input);
    }
  
    /**
     * 用户地址创建或则修改
     */
    @RequestMapping(value = "/CreateOrEdit", method = RequestMethod.POST)
    public UserAddressDto CreateOrEdit(@RequestBody UserAddressDto input) throws Exception {
        return _UserAddressService.CreateOrEdit(input);
    }
    /**
     * 用户地址删除
     */
    @RequestMapping(value = "/Delete", method = RequestMethod.POST)
    public void Delete(@RequestBody IdInput input)
    {
        _UserAddressService.removeById(input.getId());
    }

    /**
     * 用户地址批量删除
     */
    @RequestMapping(value = "/BatchDelete", method = RequestMethod.POST)
    public void BatchDelete(@RequestBody IdsInput input)
    {
        _UserAddressService.removeByIds(input.getIds());
    }

    /**
     * 用户地址导入
     */
    @RequestMapping(value = "/Import", method = RequestMethod.POST)
    public void Import(MultipartFile file, HttpServletRequest request) throws IOException {
        if(file==null)
        {
            throw  new CustomException("导入的文件不能为空");
        }      
    }

    /**
     * 用户地址导出
     */
    @RequestMapping(value = "/Export", method = RequestMethod.POST)
    public void Export(HttpServletRequest request)
    {
    }
}
